#include <Arduino.h>

// put function declarations here:
int leds[8] = {A3, 12, 2, A0, 9, 3, 8, 5};   // 点阵屏正极引脚
int gnds[8] = {13, 7, 6, A2, 4, A1, 11, 10}; // 点阵屏负极引脚
int row_pin = 5;
int col_pin = 4;
int row_val = 0;
int col_val = 0;

void setup()
{
  // put your setup code here, to run once:
  for (int i = 0; i < 8; i++)
  {
    pinMode(leds[i], OUTPUT);
    pinMode(gnds[i], OUTPUT);
    digitalWrite(gnds[i], HIGH); // 负极引脚拉高，熄灭所有LED
  }
  pinMode(row_val, INPUT);
  pinMode(col_val, INPUT);
}

void loop()
{
  // put your main code here, to run repeatedly:
  digitalWrite(leds[row_val], LOW);
  digitalWrite(gnds[col_val], HIGH);

  row_val = analogRead(row_pin);
  row_val = map(row_val, 0, 1023, 0, 7);
  col_val = analogRead(col_pin);
  col_val = map(col_val, 0, 1023, 0, 7);

  digitalWrite(leds[row_val], HIGH);
  digitalWrite(gnds[col_val], LOW);
}

// put function definitions here: